package lib.classes;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class TitleBar extends HorizontalFieldManager
{
	public Field left, right;
	public TitleBar(Field _left, String title, Field _right)
	{
		super(USE_ALL_WIDTH);
		this.setBackground(BackgroundFactory.createSolidBackground(Color.DARKGRAY));
		//int width = Display.getWidth();
		this.left = _left;
		this.right = _right;
		this.add(left);
		VerticalFieldManager gfm = new VerticalFieldManager(USE_ALL_WIDTH);
		//gfm.add(left);
		
		LabelField ttle = new LabelField(title, DrawStyle.HCENTER | FIELD_HCENTER)
		{
			public void paint(Graphics g)
		    {
		        g.setColor(Color.WHITE);		        
		        super.paint(g);
		    } 
		};
		ttle.setFont(Font.getDefault().derive(Font.BOLD, 30));
		//ttle.setMargin(0, 0, 0, !(left instanceof NullField) ?  (5 + left.getPreferredWidth()): 0);
		gfm.add(ttle);
		//this.add(ttle);
		
		//right.setMargin(0, 0, 0, Display.getWidth()-ttle.getWidth()- (!(left instanceof NullField) ?  (5 + left.getPreferredWidth()): 0));
		//gfm.add(right);
		//this.add(right);
		//this.setPadding(6, 3, 6, 3);
		//gfm.setPadding(2, 2, 2, 2);
		add(gfm);
	}


}
